<?php

namespace app\common\model\ai;

use think\Model;

/**
 * Group
 */
class Group extends Model
{
    // 表名
    protected $name = 'ai_group';

    protected $append = ['desc'];

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;


    public function app(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\common\model\ai\app\Models::class, 'app_id', 'id');
    }

    public function user(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\User::class, 'user_id', 'id');
    }

    // 获取desc
    public function getDescAttr($value, $data)
    {
        return $this->app->description ?? '暂无描述';
    }
}